package ballParadigm;

import java.util.ArrayList;

import javax.swing.ImageIcon;
import javax.swing.JLabel;

public abstract class GameObjects {
	String type;
	double x;
	double y;
	boolean isBroken;
	String image;
	String brokenim;
	int WIDTH;
	int HEIGHT;
	public abstract void ballTouched(int collusionSide, ArrayList<Ball> myBall, ArrayList<JLabel> objectLabels, int indexOfObject);
	
}

// Ball classes
abstract class Ball extends GameObjects {
	double prevx;
	double prevy;
	double velocityx;
	double velocityy;
	int score;
	boolean dead;
	boolean won=false;
	
	public void moveForward(double gravity){
	    if (this.velocityx > 30) {
	        this.velocityx = 30;
	    }
	    if (this.velocityx < -30) {
	        this.velocityx = -30;
	    }
	    if (this.velocityy > 30) {
            this.velocityy = 30;
        }
        if (this.velocityy < -30) {
            this.velocityy = -30;
        }
		prevx=x;
		prevy=y;
		x=velocityx+x;
		y=velocityy+y;
		velocityy=velocityy+gravity;
	}
	public void setLocation(int x, int y){
		this.x=x;
		this.y=y;
	}
}

class Basketball extends Ball {
	public Basketball(int x, int y, double velx, double vely) {
		dead=false;
		type="basketball";
		this.x = x;
		this.y = y;
		prevx=x;
		prevy=y;
		WIDTH = 46;
		HEIGHT = 46;
		image = "/ballParadigm/basketball.png";
		brokenim = "/ballParadigm/skull.gif";
		isBroken = false;
		velocityx=velx;
		velocityy=vely;
		score=100;
	}
	Basketball(Basketball c) {
        x = c.x;
        y = c.y;
    }
	public void ballTouched(int collusionSide, ArrayList<Ball> myBall, ArrayList<JLabel> objectLabels, int indexOfObject){}
}

class Tennisball extends Ball {
	public Tennisball(int x, int y, double velx, double vely) {
		dead=false;
		type="tennisball";
		prevx=x;
		prevy=y;
		this.x = x;
		this.y = y;
		WIDTH = 26;
		HEIGHT = 28;
		image = "/ballParadigm/tennisball.png";
		brokenim = "/ballParadigm/skull.gif";
		isBroken = false;
		velocityx=velx;
		velocityy=vely;
		score=100;
	}
	Tennisball(Tennisball c) {
        x = c.x;
        y = c.y;
    }
	public void ballTouched(int collusionSide, ArrayList<Ball> myBall, ArrayList<JLabel> objectLabels, int indexOfObject){}
}

class PingPongball extends Ball {
	public PingPongball(int x, int y, double velx, double vely) {
		dead=false;
		type="pingpongball";
		prevx=x;
		prevy=y;
		this.x = x;
		this.y = y;
		WIDTH = 40;
		HEIGHT = 40;
		image = "/ballParadigm/pingpongball.png";
		brokenim = "/ballParadigm/skull.gif";
		isBroken = false;
		velocityx=velx;
		velocityy=vely;
		score=100;
	}
	PingPongball(PingPongball c) {
        x = c.x;
        y = c.y;
    }
	public void ballTouched(int collusionSide, ArrayList<Ball> myBall, ArrayList<JLabel> objectLabels, int indexOfObject){}
}

class Bowlingball extends Ball {
	public Bowlingball(int x, int y, double velx, double vely) {
		dead=false;
		type="bowlingball";
		prevx=x;
		prevy=y;
		this.x = x;
		this.y = y;
		WIDTH = 47;
		HEIGHT = 47;
		image = "/ballParadigm/bowlingball.png";
		brokenim = "/ballParadigm/skull.gif";
		isBroken = false;
		velocityx=velx;
		velocityy=vely;
		score=100;
	}
	Bowlingball(Bowlingball c) {
        x = c.x;
        y = c.y;
    }
	public void ballTouched(int collusionSide, ArrayList<Ball> myBall, ArrayList<JLabel> objectLabels, int indexOfObject){}
}

// Inanimate object classes
abstract class Inanimate extends GameObjects {
}

class Lamp extends Inanimate {
	public Lamp(int x, int y) {
		type="lamp";
		this.x = x;
		this.y = y;
		WIDTH = 46;
		HEIGHT = 76;
		image = "/ballParadigm/lamp.gif";
		brokenim = "/ballParadigm/lampbroken.gif";
		isBroken = false;
	}
	Lamp(Lamp c) {
        x = c.x;
        y = c.y;
    }
	public void ballTouched(int collusionSide, ArrayList<Ball> myBall, ArrayList<JLabel> objectLabels, int indexOfObject){
		if(myBall.get(0).type=="bowlingball"){//If bowlingball hits
			
			myBall.get(0).velocityx=myBall.get(0).velocityx-(myBall.get(0).velocityx)/4;
			myBall.get(0).velocityy=myBall.get(0).velocityy-(myBall.get(0).velocityy)/4;
			if(this.isBroken!=true){
				this.isBroken=true;
				objectLabels.get(indexOfObject+1).setIcon(new ImageIcon(freelanceGameFrame.class.getResource(this.brokenim)));
			}
			
		}else if(myBall.get(0).type=="tennisball"){//If tennisball hits
			
			if((collusionSide==1)||(collusionSide==2)||(collusionSide==8)){//Collides top of it
				myBall.get(0).velocityy=0-(myBall.get(0).velocityy-myBall.get(0).velocityy/4);
				if(Math.abs(myBall.get(0).velocityy)<0.6){
					myBall.get(0).y=this.y-myBall.get(0).HEIGHT;
					myBall.get(0).velocityy=0;
				}else
					myBall.get(0).y=this.y-myBall.get(0).HEIGHT-0.1;
			} else if(collusionSide==3){//Collides right side
				myBall.get(0).velocityx=0-myBall.get(0).velocityx;
				myBall.get(0).x=this.x+this.WIDTH+1;
			}else if((collusionSide==4)||(collusionSide==5)||(collusionSide==6)){//Collides bottom of it
				myBall.get(0).velocityy=0-myBall.get(0).velocityy;
				myBall.get(0).y=this.y+this.HEIGHT+1;
			}else if(collusionSide==7){//Collides left side
				myBall.get(0).velocityx=0-myBall.get(0).velocityx;
				myBall.get(0).x=this.x-myBall.get(0).WIDTH-1;
			}
				
			
		
		}else if(myBall.get(0).type=="basketball"){//If basketball hits
			
			if(this.isBroken!=true){
				this.isBroken=true;
				objectLabels.get(indexOfObject+1).setIcon(new ImageIcon(freelanceGameFrame.class.getResource(this.brokenim)));
			}
			
			if((collusionSide==1)||(collusionSide==2)||(collusionSide==8)){//Collides top of it
				myBall.get(0).velocityy=0-(myBall.get(0).velocityy-myBall.get(0).velocityy/4);
				if(Math.abs(myBall.get(0).velocityy)<0.6){
					myBall.get(0).y=this.y-myBall.get(0).HEIGHT;
					myBall.get(0).velocityy=0;
				}else
					myBall.get(0).y=this.y-myBall.get(0).HEIGHT-0.1;
			} else if(collusionSide==3){//Collides right side
				myBall.get(0).velocityx=0-myBall.get(0).velocityx;
				myBall.get(0).x=this.x+this.WIDTH+1;
			}else if((collusionSide==4)||(collusionSide==5)||(collusionSide==6)){//Collides bottom of it
				myBall.get(0).velocityy=0-myBall.get(0).velocityy;
				myBall.get(0).y=this.y+this.HEIGHT+1;
			}else if(collusionSide==7){//Collides left side
				myBall.get(0).velocityx=0-myBall.get(0).velocityx;
				myBall.get(0).x=this.x-myBall.get(0).WIDTH-1;
			}	
			
		}else if(myBall.get(0).type=="pingpongball"){//If pingpongball hits
			
			if((collusionSide==1)||(collusionSide==2)||(collusionSide==8)){//Collides top of it
				myBall.get(0).velocityy=0-(myBall.get(0).velocityy-myBall.get(0).velocityy/4);
				if(Math.abs(myBall.get(0).velocityy)<0.6){
					myBall.get(0).y=this.y-myBall.get(0).HEIGHT;
					myBall.get(0).velocityy=0;
				}else
					myBall.get(0).y=this.y-myBall.get(0).HEIGHT-0.1;
			} else if(collusionSide==3){//Collides right side
				myBall.get(0).velocityx=0-myBall.get(0).velocityx;
				myBall.get(0).x=this.x+this.WIDTH+1;
			}else if((collusionSide==4)||(collusionSide==5)||(collusionSide==6)){//Collides bottom of it
				myBall.get(0).velocityy=0-myBall.get(0).velocityy;
				myBall.get(0).y=this.y+this.HEIGHT+1;
			}else if(collusionSide==7){//Collides left side
				myBall.get(0).velocityx=0-myBall.get(0).velocityx;
				myBall.get(0).x=this.x-myBall.get(0).WIDTH-1;
			}
		}
	}
}

// Platform classes
class PlatformHorizontal extends Inanimate {
	public PlatformHorizontal(int x, int y) {
		type="platform";
		this.x = x;
		this.y = y;
		WIDTH = 96;
		HEIGHT = 16;
		image = "/ballParadigm/platformhorizontal.png";
		brokenim = "/ballParadigm/platformhorizontal.png";
		isBroken = true;
	}
	PlatformHorizontal(PlatformHorizontal c) {
        x = c.x;
        y = c.y;
    }
	public void ballTouched(int collusionSide, ArrayList<Ball> myBall, ArrayList<JLabel> objectLabels, int indexOfObject){
		if(myBall.get(0).type=="bowlingball"){//If bowlingball hits makes the velocity 0
			
			if((collusionSide==1)||(collusionSide==2)||(collusionSide==8)){//Collides top of it
				myBall.get(0).velocityy=0;
				myBall.get(0).y=this.y-myBall.get(0).HEIGHT;
			} else if(collusionSide==3){//Collides right side
				myBall.get(0).velocityx=0;
				myBall.get(0).x=this.x+this.WIDTH;
			}else if((collusionSide==4)||(collusionSide==5)||(collusionSide==6)){//Collides bottom of it
				myBall.get(0).velocityy=0;
				myBall.get(0).y=this.y+this.HEIGHT;
			}else if(collusionSide==7){//Collides left side
				myBall.get(0).velocityx=0;
				myBall.get(0).x=this.x-myBall.get(0).WIDTH;
			}
			
		}else if(myBall.get(0).type=="tennisball"){//If tennisball hits decreases the velocity 1/4
			
			if((collusionSide==1)||(collusionSide==2)||(collusionSide==8)){//Collides top of it
				myBall.get(0).velocityy=0-(myBall.get(0).velocityy-myBall.get(0).velocityy/4);
				if(Math.abs(myBall.get(0).velocityy)<0.6){
					myBall.get(0).y=this.y-myBall.get(0).HEIGHT;
					myBall.get(0).velocityy=0;
				}else
					myBall.get(0).y=this.y-myBall.get(0).HEIGHT-0.1;
			} else if(collusionSide==3){//Collides right side
				myBall.get(0).velocityx=0-(myBall.get(0).velocityx-myBall.get(0).velocityx/4);
				myBall.get(0).x=this.x+this.WIDTH+1;
			}else if((collusionSide==4)||(collusionSide==5)||(collusionSide==6)){//Collides bottom of it
				myBall.get(0).velocityy=0-(myBall.get(0).velocityy-myBall.get(0).velocityy/4);
				myBall.get(0).y=this.y+this.HEIGHT+1;
			}else if(collusionSide==7){//Collides left side
				myBall.get(0).velocityx=0-(myBall.get(0).velocityx-myBall.get(0).velocityx/4);
				myBall.get(0).x=this.x-myBall.get(0).WIDTH-1;
			}
				
			
		
		}else if(myBall.get(0).type=="basketball"){//If basketball hits decreases the velocity 1/2
			

			if((collusionSide==1)||(collusionSide==2)||(collusionSide==8)){//Collides top of it
				myBall.get(0).velocityy=0-(myBall.get(0).velocityy-myBall.get(0).velocityy/4);
				if(Math.abs(myBall.get(0).velocityy)<0.6){
					myBall.get(0).y=this.y-myBall.get(0).HEIGHT;
					myBall.get(0).velocityy=0;
				}else
					myBall.get(0).y=this.y-myBall.get(0).HEIGHT-0.1;
			} else if(collusionSide==3){//Collides right side
				myBall.get(0).velocityx=0-(myBall.get(0).velocityx-myBall.get(0).velocityx/2);
				myBall.get(0).x=this.x+this.WIDTH+1;
			}else if((collusionSide==4)||(collusionSide==5)||(collusionSide==6)){//Collides bottom of it
				myBall.get(0).velocityy=0-(myBall.get(0).velocityy-myBall.get(0).velocityy/2);
				myBall.get(0).y=this.y+this.HEIGHT+1;
			}else if(collusionSide==7){//Collides left side
				myBall.get(0).velocityx=0-(myBall.get(0).velocityx-myBall.get(0).velocityx/2);
				myBall.get(0).x=this.x-myBall.get(0).WIDTH-1;
			}
			
		}else if(myBall.get(0).type=="pingpongball"){//If pingpongball hits decreases the velocity 1/16
			
			if((collusionSide==1)||(collusionSide==2)||(collusionSide==8)){//Collides top of it
				myBall.get(0).velocityy=0-(myBall.get(0).velocityy-myBall.get(0).velocityy/4);
				if(Math.abs(myBall.get(0).velocityy)<0.6){
					myBall.get(0).y=this.y-myBall.get(0).HEIGHT;
					myBall.get(0).velocityy=0;
				}else
					myBall.get(0).y=this.y-myBall.get(0).HEIGHT-0.1;
			} else if(collusionSide==3){//Collides right side
				myBall.get(0).velocityx=0-(myBall.get(0).velocityx-myBall.get(0).velocityx/16);
				myBall.get(0).x=this.x+this.WIDTH+1;
			}else if((collusionSide==4)||(collusionSide==5)||(collusionSide==6)){//Collides bottom of it
				myBall.get(0).velocityy=0-(myBall.get(0).velocityy-myBall.get(0).velocityy/16);
				myBall.get(0).y=this.y+this.HEIGHT+1;
			}else if(collusionSide==7){//Collides left side
				myBall.get(0).velocityx=0-(myBall.get(0).velocityx-myBall.get(0).velocityx/16);
				myBall.get(0).x=this.x-myBall.get(0).WIDTH-1;
			}
		}
	}
}
class PlatformVertical extends Inanimate {
	public PlatformVertical(int x, int y) {
		type="platform";
		this.x = x;
		this.y = y;
		WIDTH = 16;
		HEIGHT = 96;
		image = "/ballParadigm/platformvertical.png";
		brokenim = "/ballParadigm/platformvertical.png";
		isBroken = true;
	}
	PlatformVertical(PlatformVertical c) {
        x = c.x;
        y = c.y;
    }
	public void ballTouched(int collusionSide, ArrayList<Ball> myBall, ArrayList<JLabel> objectLabels, int indexOfObject){
		if(myBall.get(0).type=="bowlingball"){//If bowlingball hits makes the velocity 0
			
			if((collusionSide==1)||(collusionSide==2)||(collusionSide==8)){//Collides top of it
				myBall.get(0).velocityy=0;
				myBall.get(0).y=this.y-myBall.get(0).HEIGHT;
			} else if(collusionSide==3){//Collides right side
				myBall.get(0).velocityx=0;
				myBall.get(0).x=this.x+this.WIDTH;
			}else if((collusionSide==4)||(collusionSide==5)||(collusionSide==6)){//Collides bottom of it
				myBall.get(0).velocityy=0;
				myBall.get(0).y=this.y+this.HEIGHT;
			}else if(collusionSide==7){//Collides left side
				myBall.get(0).velocityx=0;
				myBall.get(0).x=this.x-myBall.get(0).WIDTH;
			}
			
		}else if(myBall.get(0).type=="tennisball"){//If tennisball hits decreases the velocity 1/4
			
			if((collusionSide==1)||(collusionSide==2)||(collusionSide==8)){//Collides top of it
				myBall.get(0).velocityy=0-(myBall.get(0).velocityy-myBall.get(0).velocityy/4);
				if(Math.abs(myBall.get(0).velocityy)<0.6){
					myBall.get(0).y=this.y-myBall.get(0).HEIGHT;
					myBall.get(0).velocityy=0;
				}else
					myBall.get(0).y=this.y-myBall.get(0).HEIGHT-0.1;
			} else if(collusionSide==3){//Collides right side
				myBall.get(0).velocityx=0-(myBall.get(0).velocityx-myBall.get(0).velocityx/4);
				myBall.get(0).x=this.x+this.WIDTH+1;
			}else if((collusionSide==4)||(collusionSide==5)||(collusionSide==6)){//Collides bottom of it
				myBall.get(0).velocityy=0-(myBall.get(0).velocityy-myBall.get(0).velocityy/4);
				myBall.get(0).y=this.y+this.HEIGHT+1;
			}else if(collusionSide==7){//Collides left side
				myBall.get(0).velocityx=0-(myBall.get(0).velocityx-myBall.get(0).velocityx/4);
				myBall.get(0).x=this.x-myBall.get(0).WIDTH-1;
			}
				
			
		
		}else if(myBall.get(0).type=="basketball"){//If basketball hits decreases the velocity 1/2
			

			if((collusionSide==1)||(collusionSide==2)||(collusionSide==8)){//Collides top of it
				myBall.get(0).velocityy=0-(myBall.get(0).velocityy-myBall.get(0).velocityy/4);
				if(Math.abs(myBall.get(0).velocityy)<0.6){
					myBall.get(0).y=this.y-myBall.get(0).HEIGHT;
					myBall.get(0).velocityy=0;
					System.out.println("Hello!");
				}else
					myBall.get(0).y=this.y-myBall.get(0).HEIGHT-0.1;
			} else if(collusionSide==3){//Collides right side
				myBall.get(0).velocityx=0-(myBall.get(0).velocityx-myBall.get(0).velocityx/2);
				myBall.get(0).x=this.x+this.WIDTH+1;
			}else if((collusionSide==4)||(collusionSide==5)||(collusionSide==6)){//Collides bottom of it
				myBall.get(0).velocityy=0-(myBall.get(0).velocityy-myBall.get(0).velocityy/2);
				myBall.get(0).y=this.y+this.HEIGHT+1;
			}else if(collusionSide==7){//Collides left side
				myBall.get(0).velocityx=0-(myBall.get(0).velocityx-myBall.get(0).velocityx/2);
				myBall.get(0).x=this.x-myBall.get(0).WIDTH-1;
			}
			
		}else if(myBall.get(0).type=="pingpongball"){//If pingpongball hits decreases the velocity 1/16
			
			if((collusionSide==1)||(collusionSide==2)||(collusionSide==8)){//Collides top of it
				myBall.get(0).velocityy=0-(myBall.get(0).velocityy-myBall.get(0).velocityy/4);
				if(Math.abs(myBall.get(0).velocityy)<0.6){
					myBall.get(0).y=this.y-myBall.get(0).HEIGHT;
					myBall.get(0).velocityy=0;
				}else
					myBall.get(0).y=this.y-myBall.get(0).HEIGHT-0.1;
			} else if(collusionSide==3){//Collides right side
				myBall.get(0).velocityx=0-(myBall.get(0).velocityx-myBall.get(0).velocityx/16);
				myBall.get(0).x=this.x+this.WIDTH+1;
			}else if((collusionSide==4)||(collusionSide==5)||(collusionSide==6)){//Collides bottom of it
				myBall.get(0).velocityy=0-(myBall.get(0).velocityy-myBall.get(0).velocityy/16);
				myBall.get(0).y=this.y+this.HEIGHT+1;
			}else if(collusionSide==7){//Collides left side
				myBall.get(0).velocityx=0-(myBall.get(0).velocityx-myBall.get(0).velocityx/16);
				myBall.get(0).x=this.x-myBall.get(0).WIDTH-1;
			}
		}
	}
}

class SpringVertical extends Inanimate {
	public SpringVertical(int x, int y) {
		type="spring";
		this.x = x;
		this.y = y;
		WIDTH = 40;
		HEIGHT = 54;
		image = "/ballParadigm/springvertical.png";
		brokenim = "/ballParadigm/springvertical.png";
		isBroken = true;
	}
	SpringVertical(SpringVertical c) {
        x = c.x;
        y = c.y;
    }
	public void ballTouched(int collusionSide, ArrayList<Ball> myBall, ArrayList<JLabel> objectLabels, int indexOfObject){

			
		if((collusionSide==1)||(collusionSide==2)||(collusionSide==8)){//Collides top of it
			myBall.get(0).velocityy=0-2*myBall.get(0).velocityy;
			myBall.get(0).y=this.y-myBall.get(0).HEIGHT-0.1;
		} else if(collusionSide==3){//Collides right side
			myBall.get(0).velocityx=0-myBall.get(0).velocityx;
			myBall.get(0).x=this.x+this.WIDTH+0.1;
		}else if((collusionSide==4)||(collusionSide==5)||(collusionSide==6)){//Collides bottom of it
			myBall.get(0).velocityy=0-2*myBall.get(0).velocityy;
			myBall.get(0).y=this.y+this.HEIGHT+0.1;
		}else if(collusionSide==7){//Collides left side
			myBall.get(0).velocityx=0-myBall.get(0).velocityx;
			myBall.get(0).x=this.x-myBall.get(0).WIDTH-0.1;
		}
			

	}
}

class SpringHorizontal extends Inanimate {
	public SpringHorizontal(int x, int y) {
		type="spring";
		this.x = x;
		this.y = y;
		WIDTH = 54;
		HEIGHT = 40;
		image = "/ballParadigm/springhorizontal.png";
		brokenim = "/ballParadigm/springhorizontal.png";
		isBroken = true;
	}
	SpringHorizontal(SpringHorizontal c) {
        x = c.x;
        y = c.y;
    }
	public void ballTouched(int collusionSide, ArrayList<Ball> myBall, ArrayList<JLabel> objectLabels, int indexOfObject){
		
		if((collusionSide==1)||(collusionSide==2)||(collusionSide==8)){//Collides top of it
			myBall.get(0).velocityy=0-(myBall.get(0).velocityy-myBall.get(0).velocityy/4);
			if(Math.abs(myBall.get(0).velocityy)<0.6){
				myBall.get(0).y=this.y-myBall.get(0).HEIGHT;
				myBall.get(0).velocityy=0;
			}else
				myBall.get(0).y=this.y-myBall.get(0).HEIGHT-0.1;
		} else if(collusionSide==3){//Collides right side
			myBall.get(0).velocityx=0-10*myBall.get(0).velocityx;
			myBall.get(0).x=this.x+this.WIDTH+0.1;
		}else if((collusionSide==4)||(collusionSide==5)||(collusionSide==6)){//Collides bottom of it
			myBall.get(0).velocityy=0-myBall.get(0).velocityy;
			myBall.get(0).y=this.y+this.HEIGHT+0.1;
		}else if(collusionSide==7){//Collides left side
			myBall.get(0).velocityx=0-10*myBall.get(0).velocityx;
			myBall.get(0).x=this.x-myBall.get(0).WIDTH-0.1;
		}
	}
}

class Trampoline extends Inanimate {
	public Trampoline(int x, int y) {
		type="trampoline";
		this.x = x;
		this.y = y;
		WIDTH = 70;
		HEIGHT = 13;
		image = "/ballParadigm/trampoline.gif";
		brokenim = "/ballParadigm/trampoline.gif";
		isBroken = true;
	}
	Trampoline(Trampoline c) {
        x = c.x;
        y = c.y;
    }
	public void ballTouched(int collusionSide, ArrayList<Ball> myBall, ArrayList<JLabel> objectLabels, int indexOfObject){

			
		if((collusionSide==1)||(collusionSide==2)||(collusionSide==8)){//Collides top of it
			myBall.get(0).velocityy=0-2*myBall.get(0).velocityy;
			myBall.get(0).y=this.y-myBall.get(0).HEIGHT-1;
		} else if(collusionSide==3){//Collides right side
			myBall.get(0).velocityx=0-myBall.get(0).velocityx;
			myBall.get(0).x=this.x+this.WIDTH+1;
		}else if((collusionSide==4)||(collusionSide==5)||(collusionSide==6)){//Collides bottom of it
			myBall.get(0).velocityy=0-myBall.get(0).velocityy;
			myBall.get(0).y=this.y+this.HEIGHT+1;
		}else if(collusionSide==7){//Collides left side
			myBall.get(0).velocityx=0-myBall.get(0).velocityx;
			myBall.get(0).x=this.x-myBall.get(0).WIDTH-1;
		}
		
	}
}

class LavaFloor extends Inanimate {
	public LavaFloor(int x, int y) {
		type="lavafloor";
		this.x = x;
		this.y = y;
		WIDTH = 624;
		HEIGHT = 66;
		image = "/ballParadigm/lavafloor.png";
		brokenim = "/ballParadigm/lavafloor.png";
		isBroken = true;
	}
	LavaFloor(LavaFloor c) {
        x = c.x;
        y = c.y;
    }
	public void ballTouched(int collusionSide, ArrayList<Ball> myBall, ArrayList<JLabel> objectLabels, int indexOfObject){

		myBall.get(0).dead=true;
		
	}
}

class Wall extends Inanimate {
	String crackim;
	boolean isCracked;
	ArrayList<String> ballsCanCrack;
	public Wall(int x, int y) {
		type="wall";
		this.x = x;
		this.y = y;
		WIDTH = 120;
		HEIGHT = 62;
		image = "/ballParadigm/wall.png";
		brokenim = "/ballParadigm/wallbroken.png";
		crackim="/ballParadigm/wallcracked.png";
		isBroken = false;
		isCracked = false;
	}
	Wall(Wall c) {
        x = c.x;
        y = c.y;
    }
	public void ballTouched(int collusionSide, ArrayList<Ball> myBall, ArrayList<JLabel> objectLabels, int indexOfObject){
		if(myBall.get(0).type=="bowlingball"){//If bowlingball hits
			

			if(this.isBroken!=true){
				this.isBroken=true;
				objectLabels.get(indexOfObject+1).setIcon(new ImageIcon(freelanceGameFrame.class.getResource(this.brokenim)));
				myBall.get(0).velocityx=myBall.get(0).velocityx-(myBall.get(0).velocityx)/4;
				myBall.get(0).velocityy=myBall.get(0).velocityy-(myBall.get(0).velocityy)/4;
			}
			
		}else if(myBall.get(0).type=="tennisball"){//If tennisball hits
			
			if(this.isCracked==false){
				this.isCracked=true;
				objectLabels.get(indexOfObject+1).setIcon(new ImageIcon(freelanceGameFrame.class.getResource(this.crackim)));
			}
			
			if((collusionSide==1)||(collusionSide==2)||(collusionSide==8)){//Collides top of it
				myBall.get(0).velocityy=0-(myBall.get(0).velocityy-myBall.get(0).velocityy/4);
				if(Math.abs(myBall.get(0).velocityy)<0.6){
					myBall.get(0).y=this.y-myBall.get(0).HEIGHT;
					myBall.get(0).velocityy=0;
				}else
					myBall.get(0).y=this.y-myBall.get(0).HEIGHT-0.1;
			} else if(collusionSide==3){//Collides right side
				myBall.get(0).velocityx=0-myBall.get(0).velocityx;
				myBall.get(0).x=this.x+this.WIDTH+1;
			}else if((collusionSide==4)||(collusionSide==5)||(collusionSide==6)){//Collides bottom of it
				myBall.get(0).velocityy=0-myBall.get(0).velocityy;
				myBall.get(0).y=this.y+this.HEIGHT+1;
			}else if(collusionSide==7){//Collides left side
				myBall.get(0).velocityx=0-myBall.get(0).velocityx;
				myBall.get(0).x=this.x-myBall.get(0).WIDTH-1;
			}
				
			
		
		}else if(myBall.get(0).type=="basketball"){//If basketball hits
			
			if(this.isCracked==false){
				this.isCracked=true;
				objectLabels.get(indexOfObject+1).setIcon(new ImageIcon(freelanceGameFrame.class.getResource(this.crackim)));
			}
			
			if((collusionSide==1)||(collusionSide==2)||(collusionSide==8)){//Collides top of it
				myBall.get(0).velocityy=0-(myBall.get(0).velocityy-myBall.get(0).velocityy/4);
				if(Math.abs(myBall.get(0).velocityy)<0.6){
					myBall.get(0).y=this.y-myBall.get(0).HEIGHT;
					myBall.get(0).velocityy=0;
				}else
					myBall.get(0).y=this.y-myBall.get(0).HEIGHT-0.1;
			} else if(collusionSide==3){//Collides right side
				myBall.get(0).velocityx=0-myBall.get(0).velocityx;
				myBall.get(0).x=this.x+this.WIDTH+1;
			}else if((collusionSide==4)||(collusionSide==5)||(collusionSide==6)){//Collides bottom of it
				myBall.get(0).velocityy=0-myBall.get(0).velocityy;
				myBall.get(0).y=this.y+this.HEIGHT+1;
			}else if(collusionSide==7){//Collides left side
				myBall.get(0).velocityx=0-myBall.get(0).velocityx;
				myBall.get(0).x=this.x-myBall.get(0).WIDTH-1;
			}	
			
		}else if(myBall.get(0).type=="pingpongball"){//If pingpongball hits
			
			if((collusionSide==1)||(collusionSide==2)||(collusionSide==8)){//Collides top of it
				myBall.get(0).velocityy=0-(myBall.get(0).velocityy-myBall.get(0).velocityy/4);
				if(Math.abs(myBall.get(0).velocityy)<0.6){
					myBall.get(0).y=this.y-myBall.get(0).HEIGHT;
					myBall.get(0).velocityy=0;
				}else
					myBall.get(0).y=this.y-myBall.get(0).HEIGHT-0.1;
			} else if(collusionSide==3){//Collides right side
				myBall.get(0).velocityx=0-myBall.get(0).velocityx;
				myBall.get(0).x=this.x+this.WIDTH+1;
			}else if((collusionSide==4)||(collusionSide==5)||(collusionSide==6)){//Collides bottom of it
				myBall.get(0).velocityy=0-myBall.get(0).velocityy;
				myBall.get(0).y=this.y+this.HEIGHT+1;
			}else if(collusionSide==7){//Collides left side
				myBall.get(0).velocityx=0-myBall.get(0).velocityx;
				myBall.get(0).x=this.x-myBall.get(0).WIDTH-1;
			}
		}
	}
}

class BarbedWire extends Inanimate {
	public BarbedWire(int x, int y) {
		this.x = x;
		this.y = y;
		WIDTH = 38;
		HEIGHT = 41;
		image = "/ballParadigm/barbedwire.png";
		brokenim = "/ballParadigm/barbedwirebroken.png";
		isBroken = false;
	}
	BarbedWire(BarbedWire c) {
        x = c.x;
        y = c.y;
    }
	public void ballTouched(int collusionSide, ArrayList<Ball> myBall, ArrayList<JLabel> objectLabels, int indexOfObject){
		if(myBall.get(0).type=="bowlingball"){//If bowlingball hits it loses 1/2 of its velocity and breaks the wire
			if(isBroken==false){
				myBall.get(0).velocityx=myBall.get(0).velocityx-(myBall.get(0).velocityx)/2;
				myBall.get(0).velocityy=myBall.get(0).velocityy-(myBall.get(0).velocityy)/2;
				this.isBroken=true;
				objectLabels.get(indexOfObject+1).setIcon(new ImageIcon(freelanceGameFrame.class.getResource(this.brokenim)));
			}
			
		}else //Other balls die, it kills them yea it just kills them :'(
			myBall.get(0).dead=true;
	}
}

// Cosmetic object classes
abstract class Cosmetic extends GameObjects {
}

class TrafficSign extends Cosmetic {
	boolean pingpongTouched = false;
	public TrafficSign(int x, int y) {
		this.x = x;
		this.y = y;
		WIDTH = 23;
		HEIGHT = 60;
		image = "/ballParadigm/trafficsign.png";
		brokenim = "/ballParadigm/trafficsignbroken.png";
		isBroken = false;
	}
	TrafficSign(TrafficSign c) {
        x = c.x;
        y = c.y;
    }
	public void ballTouched(int collusionSide, ArrayList<Ball> myBall, ArrayList<JLabel> objectLabels, int indexOfObject){
		if(myBall.get(0).type=="pingpongball"){//If pingpongball hits it loses 1/4 of its velocity
			if(pingpongTouched==false){
				myBall.get(0).velocityx=myBall.get(0).velocityx-(myBall.get(0).velocityx)/4;
				myBall.get(0).velocityy=myBall.get(0).velocityy-(myBall.get(0).velocityy)/4;
				myBall.get(0).score=myBall.get(0).score-5;
				pingpongTouched=true;
			}
		}else{ //Other balls die break the sign and loses 1/4 of their velocities
			if(this.isBroken!=true){
				this.isBroken=true;
				objectLabels.get(indexOfObject+1).setIcon(new ImageIcon(freelanceGameFrame.class.getResource(this.brokenim)));
				myBall.get(0).score=myBall.get(0).score-5;
				myBall.get(0).velocityx=myBall.get(0).velocityx-(myBall.get(0).velocityx)/4;
				myBall.get(0).velocityy=myBall.get(0).velocityy-(myBall.get(0).velocityy)/4;
			}
		}
	}
}

class Window extends Cosmetic {
	public Window(int x, int y) {
		type="pot";
		this.x = x;
		this.y = y;
		WIDTH = 20;
		HEIGHT = 32;
		image = "/ballParadigm/window.png";
		brokenim = "/ballParadigm/windowbroken.png";
		isBroken = false;
	}
	Window(Window c) {
        x = c.x;
        y = c.y;
    }
	public void ballTouched(int collusionSide, ArrayList<Ball> myBall, ArrayList<JLabel> objectLabels, int indexOfObject){

		if(this.isBroken!=true){
			this.isBroken=true;
			objectLabels.get(indexOfObject+1).setIcon(new ImageIcon(freelanceGameFrame.class.getResource(this.brokenim)));
			myBall.get(0).score=myBall.get(0).score-5;
		}

	}
}

class Pot extends Cosmetic {
	public Pot(int x, int y) {
		type="pot";
		this.x = x;
		this.y = y;
		WIDTH = 20;
		HEIGHT = 32;
		image = "/ballParadigm/flowerpot.gif";
		brokenim = "/ballParadigm/flowerpotbroken.gif";
		isBroken = false;
	}
	Pot(Pot c) {
        x = c.x;
        y = c.y;
    }
	public void ballTouched(int collusionSide, ArrayList<Ball> myBall, ArrayList<JLabel> objectLabels, int indexOfObject){

		if(this.isBroken!=true){
			this.isBroken=true;
			objectLabels.get(indexOfObject+1).setIcon(new ImageIcon(freelanceGameFrame.class.getResource(this.brokenim)));
			myBall.get(0).score=myBall.get(0).score-5;
		}
	}
}

class Teyze extends Cosmetic {
	String crackim;
	boolean isCracked;
	ArrayList<String> ballsCanCrack;
	public Teyze(int x, int y) {
		type="teyze";
		this.x = x;
		this.y = y;
		WIDTH = 51;
		HEIGHT = 72;
		image = "/ballParadigm/teyze.gif";
		brokenim = "/ballParadigm/teyzebroken.gif";
		crackim="/ballParadigm/teyzecracked.png";
		isBroken = false;
		isCracked=false;
	}
	Teyze(Teyze c) {
        x = c.x;
        y = c.y;
    }
	public void ballTouched(int collusionSide, ArrayList<Ball> myBall, ArrayList<JLabel> objectLabels, int indexOfObject){
		if(myBall.get(0).type=="bowlingball"){//If bowlingball hits
			
			if(this.isBroken!=true){
				this.isBroken=true;
				objectLabels.get(indexOfObject+1).setIcon(new ImageIcon(freelanceGameFrame.class.getResource(this.brokenim)));
				myBall.get(0).score=myBall.get(0).score-5;
			}
			
		}else if(myBall.get(0).type=="tennisball"){//If tennisball hits
			
			if(this.isCracked==false){
				this.isCracked=true;
				objectLabels.get(indexOfObject+1).setIcon(new ImageIcon(freelanceGameFrame.class.getResource(this.crackim)));
				myBall.get(0).score=myBall.get(0).score-5;
			}
				
			
		
		}else if(myBall.get(0).type=="basketball"){//If basketball hits
			
			if(this.isBroken!=true){
				this.isBroken=true;
				objectLabels.get(indexOfObject+1).setIcon(new ImageIcon(freelanceGameFrame.class.getResource(this.brokenim)));
				myBall.get(0).score=myBall.get(0).score-5;
			}
			
		}else if(myBall.get(0).type=="pingpongball"){//If pingpongball hits
			
			if(this.isCracked==false){
				this.isCracked=true;
				objectLabels.get(indexOfObject+1).setIcon(new ImageIcon(freelanceGameFrame.class.getResource(this.crackim)));
				myBall.get(0).score=myBall.get(0).score-5;
			}
		}

	}
}

class Esnaf extends Cosmetic {
	public Esnaf(int x, int y) {
		type="esnaf";
		this.x = x;
		this.y = y;
		WIDTH = 51;
		HEIGHT = 72;
		image = "/ballParadigm/esnaf.gif";
		brokenim = "/ballParadigm/esnafbroken.gif";
		isBroken = false;
	}
	Esnaf(Esnaf c) {
        x = c.x;
        y = c.y;
    }
	public void ballTouched(int collusionSide, ArrayList<Ball> myBall, ArrayList<JLabel> objectLabels, int indexOfObject){
		if(this.isBroken!=true){
			this.isBroken=true;
			objectLabels.get(indexOfObject+1).setIcon(new ImageIcon(freelanceGameFrame.class.getResource(this.brokenim)));
			myBall.get(0).score=myBall.get(0).score-5;
		}
	}
}

class Cat extends Cosmetic {
	public Cat(int x, int y) {
		type="esnaf";
		this.x = x;
		this.y = y;
		WIDTH = 51;
		HEIGHT = 40;
		image = "/ballParadigm/cat.gif";
		brokenim = "/ballParadigm/catbroken.gif";
		isBroken = false;
	}
	Cat(Cat c) {
        x = c.x;
        y = c.y;
    }
	public void ballTouched(int collusionSide, ArrayList<Ball> myBall, ArrayList<JLabel> objectLabels, int indexOfObject){
		if(this.isBroken!=true){
			this.isBroken=true;
			objectLabels.get(indexOfObject+1).setIcon(new ImageIcon(freelanceGameFrame.class.getResource(this.brokenim)));
			myBall.get(0).score=myBall.get(0).score-5;
		}
	}
}

class Building extends Cosmetic{
	public Building(int x, int y, int buildingtype) {
		
		if(buildingtype==1){
			WIDTH = 152;
			HEIGHT = 190;
			image="/ballParadigm/ev1.png";
		}else if(buildingtype==2){
			WIDTH = 111;
			HEIGHT = 232;
			image="/ballParadigm/ev2.png";
		}
		
		type="building";
		this.x = x;
		this.y = y;
		brokenim = "/ballParadigm/teyzebroken.png";
		isBroken = true;
	}
	Building(Building c) {
        x = c.x;
        y = c.y;
    }

	public void ballTouched(int collusionSide, ArrayList<Ball> myBall,
			ArrayList<JLabel> objectLabels, int indexOfObject) {
		
	}
	
}

class Door extends Inanimate {
	public Door(int x, int y) {
		this.x = x;
		this.y = y;
		WIDTH = 45;
		HEIGHT = 75;
		image = "/ballParadigm/door.png";
		brokenim = "/ballParadigm/door.png";
		isBroken = true;
	}
	Door(BarbedWire c) {
        x = c.x;
        y = c.y;
    }
	public void ballTouched(int collusionSide, ArrayList<Ball> myBall, ArrayList<JLabel> objectLabels, int indexOfObject){
		myBall.get(0).won=true;
	}
}
